# coding=utf-8
# 代码文件：chapter1/ch1.13.5.py
import os

from datetime import datetime

f_name = 'data/北京房价数据.xlsx'

basename = os.path.basename(f_name)     # 返回路径中文件名部分
print(basename)                         # 北京房价数据.xlsx

dirname = os.path.dirname(f_name)       # 返回路径中目录部分
print(dirname)                          # 输出data

# 返回文件的绝对路径
print(os.path.abspath(f_name))

# 返回文件大小
print(os.path.getsize(f_name))              # 输出259983
# 返回最近访问时间
atime = datetime.fromtimestamp(os.path.getatime(f_name))
print(atime)

# 返回创建时间
ctime = datetime.fromtimestamp(os.path.getctime(f_name))
print(ctime)

# 返回修改时间
mtime = datetime.fromtimestamp(os.path.getmtime(f_name))
print(mtime)

print(os.path.isfile(dirname))          # False
print(os.path.isdir(dirname))           # True
print(os.path.isfile(f_name))           # True
print(os.path.isdir(f_name))            # False
print(os.path.exists(f_name))           # True
